package com.ruoyi.web.controller.yijing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjReferences;
import com.ruoyi.yijing.service.IYjReferencesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参考资料Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/references")
public class YjReferencesController extends BaseController
{
    @Autowired
    private IYjReferencesService yjReferencesService;

    /**
     * 查询参考资料列表
     */
    //@PreAuthorize("@ss.hasPermi('yijing:references:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjReferences yjReferences)
    {
        startPage();
        List<YjReferences> list = yjReferencesService.selectYjReferencesList(yjReferences);
        return getDataTable(list);
    }


    /**
     * 获取参考资料详细信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:references:query')")
    @GetMapping(value = "/{refId}")
    public AjaxResult getInfo(@PathVariable("refId") Long refId)
    {
        return success(yjReferencesService.selectYjReferencesByRefId(refId));
    }

    /**
     * 新增参考资料
     */
    //@PreAuthorize("@ss.hasPermi('yijing:references:add')")
    @Log(title = "参考资料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjReferences yjReferences)
    {
        return toAjax(yjReferencesService.insertYjReferences(yjReferences));
    }

    /**
     * 修改参考资料
     */
    //@PreAuthorize("@ss.hasPermi('yijing:references:edit')")
    @Log(title = "参考资料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjReferences yjReferences)
    {
        return toAjax(yjReferencesService.updateYjReferences(yjReferences));
    }


    @Log(title = "参考资料", businessType = BusinessType.UPDATE)
    @PutMapping("updateStatus")
    public AjaxResult updateStatus(@RequestBody YjReferences yjReferences)
    {
        return toAjax(yjReferencesService.updateYjReferences(yjReferences));
    }


    /**
     * 删除参考资料
     */
    //@PreAuthorize("@ss.hasPermi('yijing:references:remove')")
    @Log(title = "参考资料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refIds}")
    public AjaxResult remove(@PathVariable Long[] refIds)
    {
        return toAjax(yjReferencesService.deleteYjReferencesByRefIds(refIds));
    }
}
